#include <bits/stdc++.h>

using namespace std;
const int MAXNUM = 100000008;
const int MOD = 100000;
const int FILENUMS = 60;
const int GROUPNUM = 58;
const int SIZE = MAXNUM / GROUPNUM + 1;
const int cnt_seat = 6;
int main()
{
    unsigned long long *arr = new unsigned long long[SIZE];
    memset(arr, 0, sizeof(unsigned long long) * SIZE);
    int maxnum = 0;
    for (int idx = 1; idx <= FILENUMS; idx++)
    {
        fstream inputfile(to_string(idx) + ".txt");
        int num;
        while (!inputfile.eof())
        {
            inputfile >> num;
            maxnum = max(maxnum, num);
            unsigned long long mask = (1ULL << 63) >> (num % GROUPNUM);
            if (arr[num / GROUPNUM] & mask) {
                continue;
            }
            (++arr[num / GROUPNUM]) |= mask;
        }
        inputfile.close();
    }
    int cnt = 0;
    int c = 0;
    for (int i = 0; i < maxnum / GROUPNUM + 1; i++)
    {
        int thiscnt = ((arr[i] << GROUPNUM) >> GROUPNUM);
        cnt += thiscnt;
        if (cnt >= MOD)
        {
            cnt %= MOD;
            int thisans = (i + 1) * GROUPNUM - 1;
            int cnt_idx = -cnt;
            unsigned long long mask = (1 << cnt_seat);
            while (true) {
                if (arr[i] & mask) { cnt_idx++; }
                if(cnt_idx > 0) break;
                thisans--;
                mask <<= 1;
            }
            cout << thisans << endl;
            if ((++c) >= 10)
                break;
        }
    }
    // system("pause");
    return 0;
}
